package com.yanqu.road.server.cmd.unioncampwar;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.unionCampWar.UnionCampWar;
import com.yanqu.road.pb.worldmessage.WorldMessageProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.unioncampwar.CrossUnionCampWarMgr;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.utils.YanQuMessageUtils;

@Cmd(code = CrossProtocol.C3_UNION_CAMP_WAR_GET_CHAT, desc = "商帮看聊天")
public class CrossUnionCampWarGetChatCmd extends CrossCommand {
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        UnionCampWar.UnionCampWarGetChatReqMsg reqMsg = UnionCampWar.UnionCampWarGetChatReqMsg.parseFrom(packet.getBytes());
        WorldMessageProto.WorldMessageListMsg chatList = CrossUnionCampWarMgr.getChatList(packet.getPlayerId(), reqMsg.getMessageType());
        if (null != chatList) {
            UnionCampWar.UnionCampWarGetChatRespMsg.Builder respMsg = UnionCampWar.UnionCampWarGetChatRespMsg.newBuilder();
            respMsg.setChatListMsg(chatList);
            MessageHelper.sendPacket(serverId, packet.getPlayerId(),
                    YanQuMessageUtils.buildMessage(ClientProtocol.U_UNION_CAMP_WAR_GET_CHAT, respMsg));
        }
    }

    @Override
    public void sendData() {

    }
}
